

from selenium.webdriver.common.by import By

from base.bace_action import BassAction


class LoginPage(BassAction):#把driver传进来，全局只能有1个driver，作为魔术方法传进来
    login_link_btn=By.CLASS_NAME,"red"
    username=By.ID, "username"
    password=By.NAME, "password"
    code=By.ID,"verify_code"
    button=By.NAME,"sbtbutton"
    msg=By.CSS_SELECTOR,".layui-layer-content"

    # def find_el(self,feature):#self可以调用该类的其他方法，可以引用该类的所有变量
    #     return self.driver.find_element(*feature)#解包feature

    def click_login_link(self):
        return self.click(self.login_link_btn)
        # return self.driver.find_element().click()

    def input_username(self,username):
        return self.send_key(self.username,username)
        # return self.driver.find_element().send_keys(username)

    def input_password(self,password):
        return self.send_key(self.password,password)
        # return self.driver.find_element().send_keys(password)

    def input_verify_code(self,code):
        return self.send_key(self.code,code)
        # return self.driver.find_element().send_keys(code)

    def click_btn(self):
        # return self.find_el(self.button).click()
        return self.click(self.button)

    def get_error_msg(self):
        txt=self.get_msg(self.msg)
        # txt=self.driver.find_element().text
        return txt
